home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue63 / Docking / DockedControls3U.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-09-15  |  1.9 KB  |  68 lines

  1. unit DockedControls3U;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   ComCtrls, ToolWin, StdCtrls, ImgList, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     ToolBar1: TToolBar;
  12.     ToolButton1: TToolButton;
  13.     ToolButton2: TToolButton;
  14.     ToolButton3: TToolButton;
  15.     ToolButton4: TToolButton;
  16.     ToolButton5: TToolButton;
  17.     ImageList1: TImageList;
  18.     Label1: TLabel;
  19.     Panel1: TPanel;
  20.     Image1: TImage;
  21.     procedure ToolBar1MouseDown(Sender: TObject; Button: TMouseButton;
  22.       Shift: TShiftState; X, Y: Integer);
  23.     procedure FormCreate(Sender: TObject);
  24.     procedure ToolBar1EndDock(Sender, Target: TObject; X, Y: Integer);
  25.     procedure FormGetSiteInfo(Sender: TObject; DockClient: TControl;
  26.       var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
  27.   private
  28.     { Private declarations }
  29.   public
  30.     { Public declarations }
  31.   end;
  32.  
  33. var
  34.   Form1: TForm1;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39.  
  40. procedure TForm1.ToolBar1MouseDown(Sender: TObject; Button: TMouseButton;
  41.   Shift: TShiftState; X, Y: Integer);
  42. begin
  43. //Can do this for each control to stop undocking happening immediately,
  44. //but it is easier to write a single statement in the form's OnCreate handler
  45. {  if Button = mbLeft then
  46.     (Sender as TControl).BeginDrag(False)}
  47. end;
  48.  
  49. procedure TForm1.FormCreate(Sender: TObject);
  50. begin
  51.   Mouse.DragImmediate := False
  52. end;
  53.  
  54. procedure TForm1.ToolBar1EndDock(Sender, Target: TObject; X, Y: Integer);
  55. begin
  56.   //Make sure toolbar's Align property is reset when it gets docked in the form
  57.   if (Sender is TToolBar) and (Target is TCustomForm) then
  58.     TToolBar(Sender).Align := alTop
  59. end;
  60.  
  61. procedure TForm1.FormGetSiteInfo(Sender: TObject; DockClient: TControl;
  62.   var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
  63. begin
  64.   CanDock := DockClient is TToolBar
  65. end;
  66.  
  67. end.
  68.